package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.Alipayment;
import edu.scau.mis.pos.mapper.AlipaymentMapper;
import edu.scau.mis.pos.service.IAlipaymentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (Alipayment)表服务实现类
 *
 * @author CJW
 * @since 2024-04-24 22:31:37
 */
@Service
public class AlipaymentServiceImpl implements IAlipaymentService {
    @Resource
    private AlipaymentMapper alipaymentMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param alipayId 主键
     * @return 实例对象
     */
    @Override
    public Alipayment selectById(Long alipayId) {
        return this.alipaymentMapper.selectById(alipayId);
    }

    /**
     * 通过orderNo查询单条数据
     *
     * @param orderNo 主键
     * @return 实例对象
     */
    @Override
    public Alipayment selectByOrderNo(Long orderNo) {
        return this.alipaymentMapper.selectByOrderNo(orderNo);
    }


    /**
     * 查询指定行
     *
     * @param alipayment 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Alipayment> selectList(Alipayment alipayment) {
        return this.alipaymentMapper.selectList(alipayment);
    }

    /**
     * 新增数据
     *
     * @param alipayment 实例对象
     * @return 实例对象
     */
    @Override
    public Alipayment insert(Alipayment alipayment) {
        alipayment.setCreateTime(new Date());
        this.alipaymentMapper.insert(alipayment);
        return alipayment;
    }

    /**
     * 修改数据
     *
     * @param alipayment 实例对象
     * @return 实例对象
     */
    @Override
    public Alipayment update(Alipayment alipayment) {
        alipayment.setUpdateTime(new Date());
        this.alipaymentMapper.update(alipayment);
        return this.selectById(alipayment.getAlipayId());
    }

    /**
     * 通过主键批量删除数据
     *
     * @param alipayId 主键
     * @return 影响记录数
     */
    @Override
    public int deleteByIds(Long alipayId) {
        return this.alipaymentMapper.deleteByIds(alipayId);
    }
}
